//
//		Author: Alexandros Sigalas
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "material.h"

material ma_init(char* name)
{
	material result= (material)malloc(sizeof(struct Material));
	result->name= NULL;
	result->section= NULL;
	result->hidden= NULL;
	result->line_color.r= result->line_color.g= result->line_color.b= 0.0;
	result->fill_color.r= result->fill_color.g= result->fill_color.b= 1.0;
	result->lineweight= 0.2;
	ma_rename(result, name);
	return result;
}	

void ma_rename(material mat, char* name)
{
	assert(name);
	assert(mat);
	if (mat->name)
		free(mat->name);
	mat->name= (char*)malloc((strlen(name) + 1)*sizeof(char));
	strcpy(mat->name, name);
}
